<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" %>
<div class="my_accountSafe_settel_dv" id="GC_securitity_mobilecode">
    <span>验证码：</span>
    <input type="text" class="my_accountSafe_codeinput" placeholder="请输入验证码">
    <a class="my_accountSafe_telcode" href="javascript:;">获取验证码</a>
    <p id="GC_mobilecode_msg" class="my_accountSafe_textpoint" style="display: none;"></p>
    <div><a class="my_accountSafe_settel_nextbtn" href="javascript:;">下一步</a></div>
</div>
<script>

    var clickFlag = false;

    <%-- 获取短信验证码 --%>
    function getMobileCode() {
        var reg = new RegExp('cur');
        if (!reg.test($(this).attr("class"))) {
            $.ajax({
                url: '${basePath}v2/sms/sendcurrentuser',
                type: 'POST',
                error: function (response) {
                    $errorMsg(response);
                },
                success: function (ret) {
                    var msg = "";
                    var classname = "";
                    if (ret.result) {
                        var mobilenumber = ret.info;
                        mobilenumber = mobilenumber.substring(0, 3) + "-" + mobilenumber.substring(3, 7) + "-" + mobilenumber.substring(7, mobilenumber.length);
                        msg = "短信验证码已发送至<span>+86 " + mobilenumber + "</span>";
                        clickFlag = true;
                        classname = "my_accountSafe_textpoint";
                    } else {
                        msg = ret.info;
                        classname = "my_accountSafe_losepoint";
                    }

                    $("#GC_mobilecode_msg").html(msg).addClass(classname).show();

                }
            });
        }
    }

    <%-- 验证短信验证码 --%>
    $(".my_accountSafe_settel_nextbtn").click(function () {
        if ($(this).hasClass("cur")) {

            if (!clickFlag) {
                alert("您尚未获取短信验证码");
                return false;
            }

            var mobilecode = $(".my_accountSafe_codeinput").val();
            if (typeof(mobilecode) != "undefined" && mobilecode.length > 0) {

                $.ajax({
                    url: '${basePath}v2/sms/vaildcode',
                    type: 'GET',
                    data: {"mobileCode": mobilecode},
                    error: function (response) {
                        $errorMsg(response);
                    },
                    success: function (ret) {
                        console.log(ret);
                        if (ret.result) {
                            $("#GC_securitity_mobilecode").slideToggle(500, function () {
                                $("#GC_securitity_next").slideDown(500);
                            });
                        } else {
                            $(".my_accountSafe_textpoint").html(ret.info).show();
                        }
                    }
                });

            }
        }
    });

</script>